package demo7;

public class Test {
    public static final long count = 10_0000_00000L;
    public static void serial() {
        long begin = System.currentTimeMillis();
        long b = 0;
        for (long i = 0; i < count;i++) {
            b++;
        }
        long f = 0;
        for (long i = 0; i < count; i++) {
            f++;
        }
        long end = System.currentTimeMillis();
        System.out.println("执行的时间为 : " + (end - begin) + "ms");
    }
    public static void concurrency() throws InterruptedException {
        long begin = System.currentTimeMillis();
        Thread t1 = new Thread(() -> {
            long b = 0;
            for (long i = 0; i < count;i++) {
                b++;
            }
        });
        t1.start();
        Thread t2 = new Thread(() -> {
            long f = 0;
            for (long i = 0; i < count; i++) {
                f++;
            }
        });
        t2.start();
        t1.join();
        t2.join();
        long end = System.currentTimeMillis();
        System.out.println("执行的时间为 : " + (end - begin) + "ms");

    }
    public static void main(String[] args) throws InterruptedException {
        serial();
        concurrency();
    }
}
